package com.wzu.springbootcrud2.controller;

import com.wzu.springbootcrud2.pojo.User;
import com.wzu.springbootcrud2.service.AsynService;
import com.wzu.springbootcrud2.service.TimingService;
import org.apache.coyote.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;

@Controller
@RequestMapping("/user")
//@EnableAsync(proxyTargetClass = true)
//@EnableScheduling
public class MailAction {

    @Autowired
    AsynService asynService;
    @Autowired
    TimingService timingService;

    @RequestMapping("/mail")
    public String SendMail(HttpSession session, HttpServletResponse response) throws IOException {

        asynService.sendEmail();
        System.out.println("异步发送邮件");
        return "d:/user/userlist";
    }

    @RequestMapping("/dingshimail")
    public String SendMailasyn(HttpSession session){
        System.out.println("定时发送邮件");
        timingService.send();
        return "forward:/user/index";

    }


}
